<template>
  <div class="feature-guide">
    <div class="guide-header">
      <div class="progress-container">
        <div class="progress-bar">
          <div class="progress" :style="{ width: progress + '%' }"></div>
        </div>
        <span class="progress-text">{{ currentStep }}/{{ totalSteps }}</span>
      </div>
    </div>

    <div class="guide-content">
      <div class="feature-slide" v-for="(feature, index) in features" :key="index" v-show="currentStep === index + 1">
        <div class="feature-image">
          <div class="image-placeholder" :class="feature.iconClass">
            <div class="icon-container">
              {{ feature.icon }}
            </div>
            <div class="image-glow"></div>
          </div>
        </div>
        
        <div class="feature-info">
          <h2 class="feature-title">{{ feature.title }}</h2>
          <p class="feature-description">{{ feature.description }}</p>
          
          <div class="feature-details">
            <div class="detail-item" v-for="(detail, detailIndex) in feature.details" :key="detailIndex">
              <div class="detail-icon">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                  <polyline points="20,6 9,17 4,12"></polyline>
                </svg>
              </div>
              <span class="detail-text">{{ detail }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="guide-navigation">
      <button class="nav-btn" @click="previousStep" v-if="currentStep > 1">
        <span class="btn-icon">←</span>
        <span class="btn-text">上一步</span>
      </button>
      <button class="nav-btn primary" @click="nextStep" v-if="currentStep < totalSteps">
        <span class="btn-text">下一步</span>
        <span class="btn-icon">→</span>
      </button>
      <button class="nav-btn primary" @click="finishGuide" v-if="currentStep === totalSteps">
        <span class="btn-text">开始使用</span>
        <span class="btn-icon">✓</span>
      </button>
    </div>

    <div class="step-indicators">
      <div 
        class="indicator" 
        v-for="step in totalSteps" 
        :key="step"
        :class="{ active: step === currentStep, completed: step < currentStep }"
        @click="goToStep(step)"
      >
        <div class="indicator-inner"></div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const currentStep = ref(1)
const totalSteps = 4

const progress = computed(() => {
  return (currentStep.value / totalSteps) * 100
})

const features = [
  {
    icon: '🏥',
    iconClass: 'hospital',
    title: '智能问诊系统',
    description: '基于AI技术的智能医疗咨询，为您提供专业的健康建议',
    details: [
      '24小时在线服务',
      '多科室专业咨询',
      '智能症状分析',
      '个性化健康建议'
    ]
  },
  {
    icon: '📅',
    iconClass: 'appointment',
    title: '便捷预约服务',
    description: '一键预约专家门诊，省去排队等待的烦恼',
    details: [
      '在线预约挂号',
      '专家医生选择',
      '时间灵活安排',
      '预约提醒服务'
    ]
  },
  {
    icon: '📊',
    iconClass: 'health',
    title: '健康档案管理',
    description: '完整的个人健康档案，科学管理您的健康数据',
    details: [
      '体检报告管理',
      '用药记录追踪',
      '健康数据统计',
      '趋势分析报告'
    ]
  },
  {
    icon: '💬',
    iconClass: 'chat',
    title: '医患沟通平台',
    description: '与医生实时沟通，获得更贴心的医疗服务',
    details: [
      '在线咨询聊天',
      '图文问诊服务',
      '视频通话功能',
      '处方药品配送'
    ]
  }
]

const emit = defineEmits(['next', 'back', 'finish'])

const nextStep = () => {
  if (currentStep.value < totalSteps) {
    currentStep.value++
  } else {
    emit('next')
  }
}

const previousStep = () => {
  if (currentStep.value > 1) {
    currentStep.value--
  } else {
    emit('back')
  }
}

const goToStep = (step: number) => {
  currentStep.value = step
}

const finishGuide = () => {
  emit('finish')
}
</script>

<style scoped lang="scss">
.feature-guide {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 50%, #a8caba 100%);
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.guide-header {
  margin-bottom: 40px;
  padding: 0 10px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-text {
  font-size: 14px;
  color: #4a5568;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

.guide-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.feature-slide {
  max-width: 550px;
  width: 100%;
  text-align: center;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-image {
  margin-bottom: 40px;
}

.image-placeholder {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background: white;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  &:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  }
}

.icon-container {
  font-size: 56px;
  position: relative;
  z-index: 2;
}

.image-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.2) 0%, transparent 70%);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

.image-placeholder.hospital {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.image-placeholder.appointment {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.image-placeholder.health {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.image-placeholder.chat {
  background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
}

.feature-info {
  color: #2d3748;
}

.feature-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #2d3748, #4a5568);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.feature-description {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 30px;
  color: #4a5568;
  font-weight: 400;
}

.feature-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 25px;
}

.detail-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 1px solid rgba(102, 126, 234, 0.1);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    border-color: rgba(102, 126, 234, 0.2);
  }
}

.detail-icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
  color: #48bb78;
  flex-shrink: 0;
  
  svg {
    width: 100%;
    height: 100%;
  }
}

.detail-text {
  font-size: 15px;
  color: #4a5568;
  font-weight: 500;
}

.guide-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 0;
  gap: 20px;
}

.nav-btn {
  padding: 16px 28px;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.9);
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  }
  
  &:active {
    transform: translateY(0);
  }
}

.nav-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
  
  &:hover {
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
  }
}

.btn-icon {
  font-size: 18px;
  transition: transform 0.3s ease;
}

.nav-btn:hover .btn-icon {
  transform: scale(1.1);
}

.step-indicators {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  border: 2px solid transparent;
  
  &:hover {
    transform: scale(1.2);
  }
  
  &.active {
    background: #667eea;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
  }
  
  &.completed {
    background: #48bb78;
    
    .indicator-inner {
      opacity: 1;
    }
  }
}

.indicator-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  .feature-guide {
    padding: 15px;
  }
  
  .feature-title {
    font-size: 24px;
  }
  
  .feature-description {
    font-size: 16px;
  }
  
  .feature-details {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .detail-item {
    padding: 14px 16px;
  }
  
  .guide-navigation {
    flex-direction: column;
    gap: 15px;
  }
  
  .nav-btn {
    width: 100%;
    justify-content: center;
  }
  
  .image-placeholder {
    width: 120px;
    height: 120px;
  }
  
  .icon-container {
    font-size: 48px;
  }
}

@media (max-width: 480px) {
  .feature-title {
    font-size: 22px;
  }
  
  .feature-description {
    font-size: 15px;
  }
  
  .detail-text {
    font-size: 14px;
  }
  
  .image-placeholder {
    width: 100px;
    height: 100px;
  }
  
  .icon-container {
    font-size: 40px;
  }
}
</style> 